
package com.victor9ac.tfm.provider.endpoint;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import twitter4j.Status;

import com.victor9ac.tfm.adapter.TwitterAdapter;
import com.victor9ac.tfm.provider.api.Commentaries;
import com.victor9ac.tfm.twitter.api.TwitterService;


@Path("app")
public class TwitterEndpoint {
    
	TwitterService twitterService = TwitterService.getInstance();
	TwitterAdapter twitterAdapter = new TwitterAdapter();//FIXME
	
	
    /** Method processing HTTP GET requests, producing "text/plain" MIME media
     * type.
     * @return String that will be send back as a response of type "text/plain".
     */
    @GET
    @Path("/tweet/{key}")
    @Produces(MediaType.APPLICATION_JSON)
    public Object getIt(@PathParam("key") String keyword) {
    	List<Status> tweets = twitterService.getTweets(keyword);
    	Commentaries commentaries = twitterAdapter.adapter(tweets);
    
    	return commentaries;
    }
}
